<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>函数</title>
	</head>
	<body>
		<input type="text" id="nav" value="1" />
		<input type="submit" value="提交" onclick="sumA()"/>
		<script type="text/javascript">
			function sumA(){
			    var su=document.getElementById("nav").value;	
			    console.log(su);
				var sum=0;
				for(var i=1; i<=su; i++){
					sum+=i;
				}
				document.write(sum);
			}
		</script>
		<hr />
		<a href="03.html">上一课</a>&nbsp;
		<a href="05.html">下一课</a>
	</body>
</html>
